﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;

namespace AnyOffice.general.vehicle._operator
{
    public partial class index : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                string @operator = new VehicleDao().GetOperator(base.Conn);
                @operator = "," + @operator + ",";
                DataTable table = new UsersDao().SelectBaseAll(base.Conn);
                if (table.Rows.Count > 0)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        ListItem item = new ListItem("[" + table.Rows[i]["DeptName"].ToString() + "] " + table.Rows[i]["UserName"].ToString(), table.Rows[i]["UserId"].ToString());
                        if (@operator.IndexOf("," + table.Rows[i]["UserId"].ToString() + ",") >= 0)
                        {
                            this.pklOperator.ItemsLeft.Add(item);
                        }
                        else
                        {
                            this.pklOperator.ItemsRight.Add(item);
                        }
                    }
                }
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                string strOperator = "";
                foreach (ListItem item2 in this.pklOperator.ItemsLeft)
                {
                    strOperator = strOperator + item2.Value + ",";
                }
                new VehicleDao().UpdateOperator(base.Conn, strOperator);
                this.litMessage.Text = base.ShowPrompt("调度人员设置已保存", "index.aspx");
            }
        }


    }
}